package com.qf.im.controller;


import com.qf.im.base.BaseController;
import com.qf.im.base.R;
import com.qf.im.entity.House;
import com.qf.im.entity.vo.SearchParams;
import com.qf.im.service.HouseService;
import com.qf.im.service.IHourseSearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 房屋表(House)表控制层
 *
 * @author makejava
 * @since 2023-11-09 09:19:28
 */
@RestController
@RequestMapping("/house")
@Slf4j
public class HouseController extends BaseController<HouseService> {

    @Autowired
    private IHourseSearchService hourseSearchService;

    /**
     * 新增房屋
     * @return
     */
    @PostMapping("/insert")
    public R insert(House house){
        log.debug("【house insert】新增房屋...{}", house);
        getBaseService().save(house);
        return R.succ();
    }

    /**
     * 房屋搜索
     * @return
     */
    @PostMapping("/search")
    public R search(SearchParams searchParams){
        log.debug("【house search】房屋搜索....{}", searchParams);
        return R.succ(hourseSearchService.search(searchParams));
    }
}

